package com.baoteng.rbspy.model.proposal;

import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.baoteng.rbspy.annotation.JsoupProperty;
import com.baoteng.rbspy.util.JsoupUtil;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.google.common.collect.Lists;

/**
 * 投保单处理全流程信息
 * @author zbzpunk
 *
 */
@JsonInclude(Include.NON_EMPTY)
public class InfoFlow {

	@JsoupProperty(tag = "#bizNo")
	String bizNo;
	
	/**
	 * 支付时间
	 */
	Date payTime;
	
	List<DetailFlow> details;

	public String getBizNo() {
		return bizNo;
	}

	public void setBizNo(String bizNo) {
		this.bizNo = bizNo;
	}

	public List<DetailFlow> getDetails() {
		return details;
	}

	public void setDetails(List<DetailFlow> details) {
		this.details = details;
	}
	
	public Date getPayTime() {
		return payTime;
	}

	public void setPayTime(Date payTime) {
		this.payTime = payTime;
	}

	public void parser(Element doc) {
		details = Optional.ofNullable(details).orElse(Lists.newArrayList());
		Elements elements = doc.select("v|rect");
		if(elements!=null && elements.size()>0) {
			elements.forEach(e->{
				DetailFlow detail = new DetailFlow();
				JsoupUtil.newInstance().parse(e, detail);
				details.add(detail);
			});
		}
	}
}
